package com.study.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.study.model.dto.note.LearningNoteQueryRequest;
import com.study.model.dto.user.*;
import com.study.model.dto.user.*;
import com.study.model.entity.User;
import com.baomidou.mybatisplus.extension.service.IService;
import com.study.model.vo.UserLoginVO;
import com.study.model.vo.UserVO;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @author YS
 * @description 针对表【user(用户)】的数据库操作Service
 * @createDate 2025-01-24 15:33:54
 */
public interface UserService extends IService<User> {

    /**
     * 用户注册
     * @param userRegisterRequest
     * @return
     */

    Long userRegister(UserRegisterRequest userRegisterRequest);

    /**
     * 用户登录
     *
     * @param userLoginRequest
     * @param request
     * @return
     */
    UserLoginVO userLogin(UserLoginRequest userLoginRequest, HttpServletRequest request);

    UserVO getUserVO(User user);

    List<UserVO> getUserVOList(List<User> userList);

    /**
     * 加密密码
     *
     * @param userPassword
     * @return
     */
    String getEncryptPassword(String userPassword);

    /**
     * 获取当前登录用户
     *
     * @param request
     * @return
     */
    UserLoginVO getLoginUser(HttpServletRequest request);

    /**
     * 用户注销
     *
     * @param request
     * @return
     */
    Boolean userLogout(HttpServletRequest request);

    /**
     * 根据 id 获取用户封装信息
     * @param id
     * @return
     */
    UserVO getUserVOById(long id);

    /**
     * 创建用户
     * @param userAddRequest
     * @return
     */
    Long createUser(UserAddRequest userAddRequest);

    /**
     * 更新用户
     * @param userUpdateRequest
     * @return
     */
    Boolean updateUser(UserUpdateRequest userUpdateRequest);

    /**
     * 获取用户分页QueryWrapper
     * @param userQueryRequest
     * @return
     */
    QueryWrapper<User> getQueryWrapper(UserQueryRequest userQueryRequest);

    /**
     * 分页获取用户封装列表
     * @param userQueryRequest
     * @return
     */
    Page<UserVO> listUserVOByPage(UserQueryRequest userQueryRequest);
    /**
     * 是否为管理员
     *
     * @param user
     * @return
     */
    boolean isAdmin(UserLoginVO user);


    /**
     * 修改密码
     * @param updatePasswordRequest
     * @param request
     * @return
     */
    Boolean updatePassword(UserUpdatePasswordRequest updatePasswordRequest, HttpServletRequest request);

    /**
     * 文件上串到resources
     * @param file
     * @return
     */
    String uploadResource(MultipartFile file);
}
